package com.beyond.common.util

import java.util.regex.Pattern

/**
 * @author chenshiyang
 * @time 2022/5/22 10:51
 * @class describe
 */
object RegexUtils {
    fun isEmail(input: CharSequence?): Boolean {
        return isMatch("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$", input)
    }

    fun isUrl(input: CharSequence?): Boolean {
        return isMatch("[a-zA-z]+://[^\\\\s]*", input)
    }

    fun isMatch(regex: String, input: CharSequence?): Boolean {
        return input != null && input.isNotEmpty() && Pattern.matches(regex, input)
    }

}